/**================================================================
**　DCC编号选择窗口
**===============================================================**/
	ChooseDocumentWindow = Ext.extend(Ext.Window,{
		chooseDocumentPanel: null,
		constructor: function(config){
			Ext.apply(this,config);
			
			this.chooseDocumentPanel = new ChooseDocumentPanel();
			
			ChooseDocumentWindow.superclass.constructor.call(this, {
				id: 'win_ChooseDocument',
				title: 'DCC文档选择窗口',
				layout: 'fit',
				width: 480,
				height: 550,
				closeAction: 'hide',
				resizable: false,
				plain: true,
				modal: true,
				buttonAlign: 'center',
				items: [this.chooseDocumentPanel],
				buttons:[{
					text: '确定',
					disabled: false,
					handler: function(){
						
					}
				},{
					text: '取消',
					handler:function(){
						var chooseDocumentWindow = Ext.getCmp("win_ChooseDocument");
						chooseDocumentWindow.hide();
					}
				}]
			});
		}
	});

/** =======================================================
 *  ChooseDocumentPanel.js
 ** ==================================================== */
	var ChooseDocumentPanel = Ext.extend(Ext.Panel,{
		documentGrid: null,
		constructor: function(config){
			Ext.apply(this,config);
			
			this.documentGrid = new DocumentGrid();
			
			ChooseDocumentPanel.superclass.constructor.call(this, {
				id: 'chooseDocumentPanel',
				region: 'center',
				border: false,
				width: 600,
				height: 550,
				layout: 'fit',
				buttonAlign: 'center',
				items: [this.documentGrid]
			});
		}
	});
	

/** =======================================================
 *  DocumentGrid.js
 ** ==================================================== */
 	var DocumentGrid = Ext.extend(Ext.grid.GridPanel,{
		condition: null,
		store: null,
		cm: null,
		searchField: null,
		constructor: function(config){
			Ext.apply(this,config);
			
			this.condition = {limit:50};
			
			this.store = new Ext.data.Store({
			    baseParams: this.condition,  
				proxy: new Ext.data.HttpProxy({
					method: 'POST',  
					url:'/pdm/dcc/getDccDocumentList.htm'
				}),
				reader: new Ext.data.JsonReader({
					totalProperty: 'totalProperty',
					root: 'root',
					id: 'documentNumber'
				},[
					{name: 'documentNumber'},
					{name: 'documentName'},
					{name: 'requisitioner'}
				])
			});
			
			this.cm = new Ext.grid.ColumnModel([
					new Ext.grid.RowNumberer(),
					{header:"文件编号", dataIndex:'documentNumber', width:80, sortable:true},
					{header:"文件名称", dataIndex:'documentName', width:125},
					{header:"申请人员", dataIndex:'requisitioner', width:95}
				]);
				
			this.searchField = new Ext.ux.form.SearchField({store: this.store,width:200});
			this.store.load();
			
			DocumentGrid.superclass.constructor.call(this, {
				id: 'documentGrid',
				region: 'center',
				border: false,
				loadMask: true,
				cls: 'x-rb',
				width: 464,
				height: 478,
				viewConfig: {forceFit: true},
				ds: this.store,
				sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
				cm: this.cm,
				tbar:[
		            '查询:', this.searchField
		        ],
				bbar: new Ext.PagingToolbar({
					pageSize: 50,
					width: '100%',
					store: this.store,
					displayInfo: true,
					displayMsg: '第 {0}~{1} 条，共 {2} 条',
					emptyMsg: '没有记录',
					refreshText: '刷新',
					beforePageText: '第',
					afterPageText: '页，共 {0} 页',
					firstText: '最前页',
					prevText: '上一页',
					nextText: '下一页',
					lastText: '最后页'
				})
			});
			
			this.on('dblclick', function(rowIdx, r){
				var row = this.getSelectionModel().getSelected();
				alert(row.get("documentNumber"));
			});
		}
	});